<template>
  <el-menu
    id="nav"
    default-active="1"
    class="el-menu-vertical-demo"
    background-color="#324157"
    text-color="#fff"
    active-text-color="#ffd04b">

    <template v-for="(item) in items">
      <el-menu-item :index="item.ide" @click="jump(item.path)" v-if="item.type==type">
        <i :class="item.icon"></i>
        <span slot="title">{{item.title}}</span>
      </el-menu-item>
    </template>
  </el-menu>
</template>

<script>
  import navItems from "../../common/Navltem";

    export default {
        name: "Nav",
      data(){
          return{
            items:[],
            type: 0

          }
      },
      methods:{
          jump(path){
            console.log(path)
            this.$router.push({
              name:path
            })
          }
      },
      mounted() {//钩子函数，页面加载就执行赋值
          this.items = navItems;
          let user = this.$store.getters.getUser;
          if(user.username!=null && user.username!=''){
            this.type=user.type;
          }else{
            this.$message.error("已注销")
            this.$router.replace('/')
          }
      }

    }
</script>

<style scoped>
  #nav {
    /*height: 100%;*/
    /*height:100vh*/
    text-align: left;
    width: 200px;
  }
  .el-menu{
    height: 100vh;
  }
</style>
